package com.glory.brepda.activity.mfg;


import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.glory.brepda.R;
import com.glory.brepda.base.BaseActivity;
import com.glory.brepda.callback.CustomDialogEntityCallBack;
import com.glory.brepda.entity.LotInfoEntity;
import com.glory.brepda.entity.response.BaseResponseBean;
import com.glory.brepda.utils.NetUtils;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.model.Response;
import com.pda.platform.ui.ui_pdaplatform.callback.FreeUI_EntityCallBack;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_LogUtils;
import com.pda.platform.ui.ui_pdaplatform.view.FreeUI_ClearEditText;

import butterknife.BindView;

public class FixtureWashActivity extends BaseActivity {

    @BindView(R.id.tvTitle)
    TextView tvTitle;
    @BindView(R.id.tvBaseSubmit)
    TextView tvBaseSubmit;
    @BindView(R.id.llMain)
    LinearLayout llMain;
    @BindView(R.id.etToolID)
    FreeUI_ClearEditText etToolID;

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_fixture_wash;
    }

    @Override
    protected void initView() {
        tvTitle.setText("治具清洗");
        tvBaseSubmit.setVisibility(View.GONE);
        setMainLayout(llMain);
    }

    @Override
    protected void initData() {

        initEdit(etToolID,s->{
            FreeUI_EntityCallBack<BaseResponseBean<Object>> callBack = new CustomDialogEntityCallBack<BaseResponseBean<Object>>
                    (new TypeToken<BaseResponseBean<Object>>() {
                    }.getType(),getSupportFragmentManager(), this) {

                @Override
                public void onSuccess(Response<BaseResponseBean<Object>> response) {
                    super.onSuccess(response);
                    if (response.body().isSuccess(FixtureWashActivity.this, false, getSupportFragmentManager())) {
                        showToast("提交成功",true);
                        etToolID.setFocusable(true);
                        etToolID.setText("");
                    }
                }

                @Override
                public void onError(Response<BaseResponseBean<Object>> response) {
                    super.onError(response);
                    FreeApi_LogUtils.saveErrorMessages(response.getException(), "TOOLCLEAR");
                }
            };
            JsonObject map = new JsonObject();
            map.addProperty("ACTIONTYPE", "CLEAR");
            map.addProperty("TOOLID", s);
            NetUtils.requestPostNet("IF.TOOLCLEAR", "Common", FixtureWashActivity.this, map, callBack);
        });
    }

}